package controleur;

import hibernate.siteProduit;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.hibernate.HibernateException;


/**
 * Servlet implementation class Servlet
 */
public class Servlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
 
    /**
     * Default constructor. 
     */
    public Servlet() {
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub

		System.out.println("GET");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String Param_passe;
		int horizon_passe;
		Param_passe=request.getParameter("passe");
		horizon_passe=Integer.parseInt(Param_passe);
		System.out.println("POST");
	
		
		System.out.println("Fin");
		
		LancerPrevision toto = new LancerPrevision();
		try {
			System.out.println(Param_passe);
		    if(horizon_passe!=1)
		    {
			toto.methodeLancerPrevision(horizon_passe);
		    }
		    else
		    {
		    toto.methodeLancerPrevisionHorizon1();
		    }
		
			
		} catch (HibernateException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		getServletContext().getRequestDispatcher("/prevision_result.jsp").forward(request, response);
		//Mmc  hana = new Mmc();
		//hana.fonction ();
		


		
		
	}

}
